package com.tao.utilslib.data;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * 对象判空类
 */
public class Obj {

    /**
     * 非空
     *
     * @param os
     * @return
     */
    public static <T> boolean notNULL(T... os) {
        return !isNULL(os);
    }

    /**
     * 空
     *
     * @param os
     * @return
     */
    public static <T> boolean isNULL(T... os) {
        if (null == os)
            return true;

        for (int i = 0; i < os.length; i++) {
            if (null == os[i])
                return true;
            if (os[i] instanceof String) {
                return ((String) os[i]).length() == 0;
            }
        }
        return false;
    }

    public static <T extends Collection> boolean isNULL(T list) {
        return null == list || list.isEmpty();
    }

    public static <T extends Collection> boolean notNULL(T list) {

        return !isNULL(list);
    }

    public static <T extends Map> boolean isNULL(T map) {
        return null == map || map.size() == 0;
    }

    public static <T extends Map> boolean notNULL(T map) {
        return !isNULL(map);
    }


    public static void main(String[] args) {
        List<String> strings = new ArrayList<>();

        strings.add(null);
        strings.add(null);
        strings.add(null);
        System.err.println(isNULL(strings));

        String[] ss = new String[]{"", "1", "1"};
//        System.err.println(isNULL(null) ); 
    }
}
